package cc.rengu.igas.opms.core.service.trans.apppay;

import cc.rengu.igas.opms.common.enums.RespCodeEnum;
import cc.rengu.igas.opms.core.service.base.ManageService;
import cc.rengu.igas.opms.facade.request.MobileBankScoreQueryRequest;
import cc.rengu.igas.opms.facade.response.MobileBankScoreQueryResponse;
import cc.rengu.oltp.service.common.constant.AppParamConstant;
import cc.rengu.oltp.service.common.entity.BinInfo;
import cc.rengu.oltp.service.common.entity.ChannelCallCfg;
import cc.rengu.oltp.service.common.enums.CheckResultEnum;
import cc.rengu.oltp.service.common.enums.TransStatusEnum;
import cc.rengu.oltp.service.model.BizResponse;
import cc.rengu.oltp.service.model.OrderInfo;
import cc.rengu.oltp.service.realize.BinInfoService;
import cc.rengu.oltp.service.realize.TransCustomImpl;
import cc.rengu.oltp.service.realize.impl.BinInfoServiceImpl;
import cc.rengu.oltp.utility.util.ConvertUtil;

import java.util.List;

/**
 * 积分查询
 *
 * @author keyi
 * @modify by wangcheng
 * @date 2020/3/23.
 */
public class MobileBankScoreQueryService extends ManageService implements TransCustomImpl {
    @Override
    protected Object bizBeforeCust() throws Exception {
        MobileBankScoreQueryRequest mobileBankScoreQueryRequest = new MobileBankScoreQueryRequest();
        ConvertUtil.convertOutput(mobileBankScoreQueryRequest);
        return mobileBankScoreQueryRequest;
    }

    @Override
    protected BizResponse bizProcessCust(Object request) throws Exception {

        BizResponse<MobileBankScoreQueryResponse> bizResponse = new BizResponse<>();
        MobileBankScoreQueryRequest mobileBankScoreQueryRequest = (MobileBankScoreQueryRequest) request;
        String instId = mobileBankScoreQueryRequest.getHeader().getInstId();
        String payAcctNo = mobileBankScoreQueryRequest.getPayAcctNo();
        bizResponse.setRspSysId(AppParamConstant.SYS_ID);

        //获取卡BIN
        BinInfoService binInfoService = new BinInfoServiceImpl();
        BinInfo cardBinInfo = binInfoService.getCardBinInfo(payAcctNo);

        //TODO 积分系统查询  由项目组自行实现该接口调用

        bizResponse.setRespCode(RespCodeEnum.TRANS_SUCCESS.getRespCode());
        bizResponse.setRespDesc(RespCodeEnum.TRANS_SUCCESS.getRespDesc());
        return bizResponse;
    }

    @Override
    protected void bizAfterCust(Object response) throws Exception {
        BizResponse bizResponse = (BizResponse) response;
        MobileBankScoreQueryResponse mobileBankScoreQueryResponse = (MobileBankScoreQueryResponse) bizResponse.getResult();
        ConvertUtil.convertInput(mobileBankScoreQueryResponse);
    }

    @Override
    public ChannelCallCfg channelCallSceneDiscern(Object request, List<ChannelCallCfg> channelCallCfgList) throws Exception {
        return null;
    }

    @Override
    public CheckResultEnum channelCallPreCheck(Object request, ChannelCallCfg channelCallCfg, OrderInfo orderInfo) throws Exception {
        return null;
    }

    @Override
    public TransStatusEnum channelCallResultProc(Object request, ChannelCallCfg channelCallCfg, TransStatusEnum transStatusEnum, Object channelResponse, OrderInfo needUpdateOrderInfo) throws Exception {
        return null;
    }
}
